<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>帐目管理</title>
<link href="script/bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" media="screen">
<link type="text/css" rel="stylesheet" href="script/css/header.css">
<link type="text/css" rel="stylesheet" href="script/css/bill.css">
<link rel="stylesheet" href="script/bootstrap/css/datepicker.css">
<script src="script/bootstrap/js/jquery-1.8.2.js"></script>
<script src="script/bootstrap/js/bootstrap.js"></script>
<script src="script/bootstrap/js/bootstrap-datepicker.js"></script>
<script src="script/js/util.js"></script>
</head>
<body>
	<div id="header">
		<div class="container">
			<div class="row">
			<div class="span3">
				<h1>
					<a title="糊涂账" href="login.html" class="brand">
						<img width="154" height="49" src="script/img/logo3.png" title="糊涂账" alt="一起来记流水帐">
					</a>
				</h1>
			</div>
			<div class="span9">
				<ul class="nav nav-pills pull-right tnav-menu" style="margin:18px auto;">
					<li class="dropdown" id="accountManger">
						<a class="dropdown-toggle" data-toggle="dropdown" href="#accountManger">
							用户
							<b class="caret"></b>
						</a>
						<ul class="dropdown-menu">
							<li><a id="logoutbtn" class='btn-link'>注销</a></li>
							<li><a href="#">个人资料修改</a></li>
							<li class="divider"></li>
							<li><a href="#">给我们提建议</a></li>
						</ul>
					</li>
				</ul>
				<!-- 
				<ul class="nav nav-pills pull-right tnav-menu" style="margin:18px auto;">
					<li><a href="register.html">注销</a></li>
					<li><a href="advice.html">给我们提建议</a></li>
				</ul>
				 -->
				<ul class="nav nav-pills tlnav-menu" style="margin:18px 0px 0px -60px;">
					<li><a href="#about">我的首页</a></li>
					<li class="active"><a href="bill.html">账目管理</a></li>
					<li><a href="category.html">类别管理</a></li>
					<li><a href="account.html">账户管理</a></li>
				</ul>
			</div>
			</div>
		</div>
	</div>
	<div id="main" class="container">
		<div class="row">
			<div class="span2" style="padding:5px 0px;">
				<div>
					<ul class="nav nav-pills nav-stacked" >
						<li class="active"><a id="newBillBtn" class='btn-link'>新增账目</a></li>
						<li><a id="viewBillBtn" class='btn-link'>查询账目</a></li>
					</ul>
				</div>
			</div>
			<div class="span10" style="padding:5px 0px;">
				<div id="newBill" class="tabbable">
					<ul class="nav nav-tabs">
						<li class="active">
    						<a data-toggle="tab" href="#outTab">支出</a>
    					</li>
    					<li>
    						<a data-toggle="tab" href="#inTab">收入</a>
    					</li>
    					<li>
    						<a data-toggle="tab" href="#transTab">转账/存取</a>
    					</li>
    					<li>
    						<a data-toggle="tab" href="#borwLendTab">借款/报销</a>
    					</li>
    					<li>
    						<a data-toggle="tab" href="#credCardTab">信用卡还款</a>
    					</li>
    				</ul>
    				<div class="tab-content">
    					<div id="outTab" class="tab-pane active">
    						<form class="form-horizontal" id="newOutForm">
    							<fieldset>
    								<legend>新增支出记录</legend>
    								<div id="outDateDiv" class="control-group">
    									<label class="control-label" for="outDate">日期</label>
    									<div class="controls">
											<input type="text" id="outDate" name="date" data-date-format="yyyy-mm-dd" required>
										</div>
    								</div>
    								<div id="outTitleDiv" class="control-group">
    									<label class="control-label" for="outTitle">名称</label>
    									<div class="controls">
											<input type="text" id="outTitle" name="title">
										</div>
    								</div>
    								<div id="outAmountDiv" class="control-group">
    									<label class="control-label" for="outAmount">金额</label>
    									<div class="controls">
											<input type="text" id="outAmount" name="amount">
										</div>
    								</div>
    								<div id="outAcctIdDIV" class="control-group">
    									<label class="control-label" for="outAcctId">账户</label>
    									<div class="controls">
											<select id="outAcctId" name="acctId">
											</select>
										</div>
    								</div>
    								<div id="outCategoryIdDIV" class="control-group">
    									<label class="control-label" for="outCategoryId">类别</label>
    									<div class="controls">
											<select id="outCategoryId" name="categoryId">
											</select>
										</div>
    								</div>
    								<div id="outRemarkDIV" class="control-group">
    									<label class="control-label" for="outRemark">备注</label>
    									<div class="controls">
											<textarea rows="5" id="outRemark" name="remark"></textarea>
										</div>
    								</div>
    							</fieldset>
    							<div class="control-group">
            						<div class="controls">
            							<input id="newOutBillBtn" type="button" class="btn btn-primary" value="新增">
            						</div>
            					</div>
    						</form>
    					</div>
    					<div id="inTab" class="tab-pane">
    						<form class="form-horizontal" id="newInForm">
    							<fieldset>
    								<legend>新增收入记录</legend>
    								<div id="inDateDiv" class="control-group">
    									<label class="control-label" for="inDate">日期</label>
    									<div class="controls">
											<input type="text" id="inDate" name="date" data-date-format="yyyy-mm-dd">
										</div>
    								</div>
    								<div id="inTitleDiv" class="control-group">
    									<label class="control-label" for="inTitle">名称</label>
    									<div class="controls">
											<input type="text" id="inTitle" name="title">
										</div>
    								</div>
    								<div id="inAmountDiv" class="control-group">
    									<label class="control-label" for="inAmount">金额</label>
    									<div class="controls">
											<input type="text" id="inAmount" name="amount">
										</div>
    								</div>
    								<div id="inAcctIdDIV" class="control-group">
    									<label class="control-label" for="inAcctId">账户</label>
    									<div class="controls">
											<select id="inAcctId" name="acctId">
											</select>
										</div>
    								</div>
    								<div id="inCategoryIdDIV" class="control-group">
    									<label class="control-label" for="inCategoryId">类别</label>
    									<div class="controls">
											<select id="inCategoryId" name="categoryId">
											</select>
										</div>
    								</div>
    								<div id="inRemarkDIV" class="control-group">
    									<label class="control-label" for="inRemark">备注</label>
    									<div class="controls">
											<textarea rows="5" id="inRemark" name="remark"></textarea>
										</div>
    								</div>
    							</fieldset>
    							<div class="control-group">
            						<div class="controls">
            							<input id="newInBillBtn" type="button" class="btn btn-primary" value="新增">
            						</div>
            					</div>
    						</form>
    					</div>
    					<div id="transTab" class="tab-pane">
    						<form class="form-horizontal" id="newTransForm">
    							<fieldset>
    								<legend>新增转账/存取记录</legend>
    								<div id="transDateDiv" class="control-group">
    									<label class="control-label" for="transDate">日期</label>
    									<div class="controls">
											<input type="text" id="transDate" name="date" data-date-format="yyyy-mm-dd">
										</div>
    								</div>
    								<div id="transTitleDiv" class="control-group">
    									<label class="control-label" for="transTitle">名称</label>
    									<div class="controls">
											<input type="text" id="transTitle" name="title">
										</div>
    								</div>
    								<div id="transAmountDiv" class="control-group">
    									<label class="control-label" for="transAmount">金额</label>
    									<div class="controls">
											<input type="text" id="transAmount" name="amount">
										</div>
    								</div>
    								<div id="transSrcAcctIdDIV" class="control-group">
    									<label class="control-label" for="transSrcAcctId">转出账户</label>
    									<div class="controls">
											<select id="transSrcAcctId" name="srcAcctId">
											</select>
										</div>
    								</div>
    								<div id="transDestAcctIdDIV" class="control-group">
    									<label class="control-label" for="transDestAcctId">转入账户</label>
    									<div class="controls">
											<select id="transDestAcctId" name="destAcctId">
											</select>
										</div>
    								</div>
    								<div id="transRemarkDIV" class="control-group">
    									<label class="control-label" for="transRemark">备注</label>
    									<div class="controls">
											<textarea rows="5" id="transRemark" name="remark"></textarea>
										</div>
    								</div>
    							</fieldset>
    							<div class="control-group">
            						<div class="controls">
            							<input id="newTransBillBtn" type="button" class="btn btn-primary" value="新增">
            						</div>
            					</div>
    						</form>
    					</div>
    					<div id="borwLendTab" class="tab-pane">
    						<form class="form-horizontal" id="newBorwLendForm">
    							<fieldset>
    								<legend>新增借款/报销记录</legend>
    								<div id="borwLendDateDiv" class="control-group">
    									<label class="control-label" for="borwLendDate">日期</label>
    									<div class="controls">
											<input type="text" id="borwLendDate" name="date" data-date-format="yyyy-mm-dd">
										</div>
    								</div>
    								<div id="borwLendTitleDiv" class="control-group">
    									<label class="control-label" for="borwLendTitle">名称</label>
    									<div class="controls">
											<input type="text" id="borwLendTitle" name="title">
										</div>
    								</div>
    								<div id="borwLendAmountDiv" class="control-group">
    									<label class="control-label" for="borwLendAmount">金额</label>
    									<div class="controls">
											<input type="text" id="borwLendAmount" name="amount">
										</div>
    								</div>
    								<div id="borwLendTypeDIV" class="control-group">
    									<label class="control-label" for="borwLendType">类型</label>
    									<div class="controls">
											<label class="radio inline">
												<input type="radio" name="borwLendType" id="lend" value="0"></input>
												借出
											</label>
											<label class="radio inline">
												<input type="radio" name="borwLendType" id="borrow" value="1"></input>
												借入
											</label>
										</div>
    								</div>
    								<div id="borwLendAcctIdDIV" class="control-group">
    									<label class="control-label" for="borwLendAcctId">账户</label>
    									<div class="controls">
											<select id="borwLendAcctId" name="acctId">
											</select>
										</div>
    								</div>
    								<div id="borwLendRemarkDIV" class="control-group">
    									<label class="control-label" for="borwLendRemark">备注</label>
    									<div class="controls">
											<textarea rows="5" id="borwLendRemark" name="remark"></textarea>
										</div>
    								</div>
    							</fieldset>
    							<div class="control-group">
            						<div class="controls">
            							<input id="newBorwLendBillBtn" type="button" class="btn btn-primary" value="新增">
            						</div>
            					</div>
    						</form>
    					</div>
    					<div id="credCardTab" class="tab-pane">
    						<form class="form-horizontal" id="newCredCardForm">
    							<fieldset>
    								<legend>新增信用卡还款记录</legend>
    								<div id="credCardDateDiv" class="control-group">
    									<label class="control-label" for="credCardDate">日期</label>
    									<div class="controls">
											<input type="text" id="credCardDate" name="date" data-date-format="yyyy-mm-dd">
										</div>
    								</div>
    								<div id="credCardTitleDiv" class="control-group">
    									<label class="control-label" for="credCardTitle">名称</label>
    									<div class="controls">
											<input type="text" id="credCardTitle" name="title">
										</div>
    								</div>
    								<div id="credCardAmountDiv" class="control-group">
    									<label class="control-label" for="credCardAmount">金额</label>
    									<div class="controls">
											<input type="text" id="credCardAmount" name="amount">
										</div>
    								</div>
    								<div id="credCardSrcAcctIdDIV" class="control-group">
    									<label class="control-label" for="credCardSrcAcctId">还款账户</label>
    									<div class="controls">
											<select id="credCardSrcAcctId" name="srcAcctId">
											</select>
										</div>
    								</div>
    								<div id="credCardDestAcctIdDIV" class="control-group">
    									<label class="control-label" for="credCardDestAcctId">信用卡</label>
    									<div class="controls">
											<select id="credCardDestAcctId" name="destAcctId">
											</select>
										</div>
    								</div>
    								<div id="credCardRemarkDIV" class="control-group">
    									<label class="control-label" for="credCardRemark">备注</label>
    									<div class="controls">
											<textarea rows="5" id="credCardRemark" name="remark"></textarea>
										</div>
    								</div>
    							</fieldset>
    							<div class="control-group">
            						<div class="controls">
            							<input id="newCredCardBillBtn" type="button" class="btn btn-primary" value="新增">
            						</div>
            					</div>
    						</form>
    					</div>
    				</div>
    			</div>
    			<div id="viewBill" class="tabbable" style="padding:10px;">
    				<form class="form-horizontal">
    					<div class="control-group" style="margin-bottom: 10px;">
    						<label class="control-label" style="width: 60px;" for="beginDate">起止日期</label>
    						<div class="controls" style="margin-left: 80px;">
    							<span>从 </span><input id="beginDate" class="input-small" type="text" data-date-format="yyyy-mm-dd" required><span> 到 </span><input id="endDate" class="input-small" type="text" data-date-format="yyyy-mm-dd" required>
    						</div>
    					</div>
    					<div class="control-group" style="margin-bottom: 10px;">
    						<label class="control-label" style="width: 60px;" for="allAccount">账户</label>
    						<div id="accountDiv" class="controls" style="margin-left: 80px;">
 
    						</div>
    					</div>
    					<div class="control-group" style="margin-bottom: 10px;">
    						<label class="control-label" style="width: 60px;" for="allCategory">类别</label>
    						<div id="categoryDiv" class="controls" style="margin-left: 80px;">

    						</div>
    					</div>
    				</form>
    				<div>
    					<table id="billTab" class="table table-hover table-condensed table-bordered">
    						<thread>
								<tr>
									<th class="span2">日期</th>
									<th class="span3">名称</th>
									<th class="span2">金额（元）</th>
									<th class="span3">账户</th>
									<th class="span2">类别</th>
								</tr>
							</thread>
    					</table>
    					<div class="pull-right">
    						<select style="width: 100px;">
								<option>每页10条</option>
								<option>每页20条</option>
								<option>每页30条</option>
							</select>
    					</div>
    					<div class="pagination">
    						<ul>
    							<li class="disabled"><a href="#">&laquo;</a></li>
    							<li class="active"><a href="#">1</a></li>
    							<li><a href="#">2</a></li>
    							<li><a href="#">3</a></li>
    							<li><a href="#">4</a></li>
    							<li><a href="#">5</a></li>
    							<li><a href="#">&raquo;</a></li>
    						</ul>
    					</div>
    				</div>
    			</div>
			</div>
		</div>
	</div>
</body>
</html>

<script type="text/javascript">

function queryBillList(beginDate, endDate, acctId, categoryId, page, pageNum) {
	$('#billTab').children("tbody").remove();
	$.ajax({
		type: "POST",
		url: "business/com.heavenbird.book.action.BillAction?action=queryBill",
		data: "beginDate="+beginDate+"&endDate="+endDate+"&acctId="+acctId+"&categoryId="+categoryId+"&page="+page+"&pageNum="+pageNum,
		dataType: "json",
		success: function(data, textStatus) {
			if(data.success == true) {
				
			} else {
				
			}
		}
	});
}

function loadAccountList() {
	$.ajax({
		type: "POST",
		url: "business/com.heavenbird.book.action.AccountAction?action=queryAccountShortInfo",
		dataType: "json",
		success: function(data, textStatus) {
			if(data.success == true) {
				$('#outAcctId').empty();
				$('#inAcctId').empty();
				$('#transSrcAcctId').empty();
				$('#transDestAcctId').empty();
				$('#borwLendAcctId').empty();
				$('#credCardSrcAcctId').empty();
				$('#credCardDestAcctId').empty();
				//$("<option></option>").val('0').text('请选择').appendTo($('#outAcctId'));
				//$("<option></option>").val('0').text('请选择').appendTo($('#inAcctId'));
				//$("<option></option>").val('0').text('请选择').appendTo($('#transSrcAcctId'));
				//$("<option></option>").val('0').text('请选择').appendTo($('#transDestAcctId'));
				//$("<option></option>").val('0').text('请选择').appendTo($('#borwLendAcctId'));
				//$("<option></option>").val('0').text('请选择').appendTo($('#credCardSrcAcctId'));
				//$("<option></option>").val('0').text('请选择').appendTo($('#credCardDestAcctId'));
				$('#accountDiv').empty();
				$('#accountDiv').append('<label class="checkbox inline"><input type="checkbox" id="0" >所有</label>');
				var accountShortInfos = data.accountShortInfos;
				$.each(accountShortInfos, function(i, n) {
					$("<option></option>").val(n.acctId).text(n.acctName).appendTo($('#outAcctId'));
					$("<option></option>").val(n.acctId).text(n.acctName).appendTo($('#inAcctId'));
					$("<option></option>").val(n.acctId).text(n.acctName).appendTo($('#transSrcAcctId'));
					$("<option></option>").val(n.acctId).text(n.acctName).appendTo($('#transDestAcctId'));
					$("<option></option>").val(n.acctId).text(n.acctName).appendTo($('#borwLendAcctId'));
					$("<option></option>").val(n.acctId).text(n.acctName).appendTo($('#credCardSrcAcctId'));
					if (n.acctType == 3) {
						$("<option></option>").val(n.acctId).text(n.acctName).appendTo($('#credCardDestAcctId'));
					}
					//查询账目界面账户列表
					$('#accountDiv').append('<label class="checkbox inline"><input type="checkbox" id="' + n.acctId + '" >' + n.acctName + '</label>');
				});
			} else {
				alert(data.msg);
			}
		}
	});
}

function loadCategoryList() {
	$.ajax({
		type: "POST",
		url: "business/com.heavenbird.book.action.CategoryAction?action=getCategoryDetailList",
		dataType: "json",
		success: function(data, textStatus) {
			if(data.success == true) {
				$('#outCategoryId').empty();
				$('#inCategoryId').empty();
				//$("<option></option>").val('0').text('请选择').appendTo($('#outCategoryId'));
				//$("<option></option>").val('0').text('请选择').appendTo($('#inCategoryId'));
				$('#categoryDiv').empty();
				$('#categoryDiv').append('<label class="checkbox inline"><input type="checkbox" id="0" >所有</label>');
				var categoryLists = data.categoryDetails;
				$.each(categoryLists, function(i, n) {
					if (n.categoryType == 1) {    //支出
						if (n.parentId == -1) {
							$('#outCategoryId').append("<optgroup id='C" + n.categoryId + "' label='" + n.categoryName + "'></optgroup>");
						} else {
							var parentObj = $('#'+ 'C' + n.parentId);
							$("<option></option>").val(n.categoryId).text(n.categoryName).appendTo(parentObj);
							//查询账目界面类别列表
							$('#categoryDiv').append('<label class="checkbox inline"><input type="checkbox" id="' + n.categoryId + '" >' + n.categoryName + '</label>');
						}
					} else if (n.categoryType == 2) {    //收入
						if (n.parentId == -1) {
							$('#inCategoryId').append("<optgroup id='C" + n.categoryId + "' label='" + n.categoryName + "'></optgroup>");
						} else {
							$("<option></option>").val(n.categoryId).text(n.categoryName).appendTo($('#inCategoryId'));
							//查询账目界面类别列表
							$('#categoryDiv').append('<label class="checkbox inline"><input type="checkbox" id="' + n.categoryId + '" >' + n.categoryName + '</label>');
						}
					} else {
						if (n.parentId != -1) {
							//查询账目界面类别列表
							$('#categoryDiv').append('<label class="checkbox inline"><input type="checkbox" id="' + n.categoryId + '" >' + n.categoryName + '</label>');
						}
					}
				});
			} else {
				alert(data.msg);
			}
		}
	});
}

$(document).ready(function(){
	$("#outDate").focus(function(){
		$("#outDate").datepicker();
	});
	
	$("#inDate").focus(function(){
		$("#inDate").datepicker();
	});
	
	$("#transDate").focus(function(){
		$("#transDate").datepicker();
	});
	
	$("#borwLendDate").focus(function(){
		$("#borwLendDate").datepicker();
	});
	
	$("#credCardDate").focus(function(){
		$("#credCardDate").datepicker();
	});
	
	$("#beginDate").focus(function(){
		$("#beginDate").datepicker();
	});
	
	$("#endDate").focus(function(){
		$("#endDate").datepicker();
	});
	
	var now = date2strYYYYMMDD(new Date());
	
	$('#outDate').val(now);
	$("#inDate").val(now);
	$("#transDate").val(now);
	$("#borwLendDate").val(now);
	$("#credCardDate").val(now);
	
	var firstDate = date2strYYYYMM01(new Date());
	$('#beginDate').val(firstDate);
	$('#endDate').val(now);
	
	$('#outAmount').blur(function(){
		$(this).val(formatYuanAmount($(this).val()));
	});
	
	$('#inAmount').blur(function(){
		$(this).val(formatYuanAmount($(this).val()));
	});
	
	$('#transAmount').blur(function(){
		$(this).val(formatYuanAmount($(this).val()));
	});
	
	$('#borwLendAmount').blur(function(){
		$(this).val(formatYuanAmount($(this).val()));
	});
	
	$('#credCardAmount').blur(function(){
		$(this).val(formatYuanAmount($(this).val()));
	});
	
	loadAccountList();
	
	loadCategoryList();
	
	$('#newOutBillBtn').click(function(){
		if ($('#outDate').val() == null || $('#outDate').val() == '') {
			alert('时间不能为空！');
			return false;
		}
		if ($('#outTitle').val() == null || $('#outTitle').val() == '') {
			alert('名称不能为空！');
			return false;
		}
		if ($('#outAmount').val() == null || $('#outAmount').val() == '') {
			alert('金额不能为空！');
			return false;
		}
		if ($('#outAcctId').val() == null || $('#outAcctId').val() == '') {
			alert('账户不能为空！');
			return false;
		}
		if ($('#outCategoryId').val() == null || $('#outCategoryId').val() == '') {
			alert('类别不能为空！');
			return false;
		}
		$.ajax({
			type: "POST",
			url: "business/com.heavenbird.book.action.BillAction?action=newOutBill",
			data: $('#newOutForm').serialize(),
			dataType: "json",
			success: function(data, textStatus) {
				if(data.success == true) {
					alert('记录新增成功！');
					$('#newOutForm')[0].reset();
					now = date2strYYYYMMDD(new Date());
					$('#outDate').val(now);
				} else {
					alert(data.msg);
				}
			}
		});
	});
	
	$('#newInBillBtn').click(function(){
		if ($('#inDate').val() == null || $('#inDate').val() == '') {
			alert('时间不能为空！');
			return false;
		}
		if ($('#inTitle').val() == null || $('#inTitle').val() == '') {
			alert('名称不能为空！');
			return false;
		}
		if ($('#inAmount').val() == null || $('#inAmount').val() == '') {
			alert('金额不能为空！');
			return false;
		}
		if ($('#inAcctId').val() == null || $('#inAcctId').val() == '') {
			alert('账户不能为空！');
			return false;
		}
		if ($('#inCategoryId').val() == null || $('#inCategoryId').val() == '') {
			alert('类别不能为空！');
			return false;
		}
		$.ajax({
			type: "POST",
			url: "business/com.heavenbird.book.action.BillAction?action=newInBill",
			data: $('#newInForm').serialize(),
			dataType: "json",
			success: function(data, textStatus) {
				if(data.success == true) {
					alert('记录新增成功！');
					$('#newInForm')[0].reset();
					now = date2strYYYYMMDD(new Date());
					$('#inDate').val(now);
				} else {
					alert(data.msg);
				}
			}
		});
	});
	
	$('#newTransBillBtn').click(function(){
		if ($('#transDate').val() == null || $('#transDate').val() == '') {
			alert('时间不能为空！');
			return false;
		}
		if ($('#transTitle').val() == null || $('#transTitle').val() == '') {
			alert('名称不能为空！');
			return false;
		}
		if ($('#transAmount').val() == null || $('#transAmount').val() == '') {
			alert('金额不能为空！');
			return false;
		}
		if ($('#transSrcAcctId').val() == null || $('#transSrcAcctId').val() == '') {
			alert('转出账户不能为空！');
			return false;
		}
		if ($('#transDestAcctId').val() == null || $('#transDestAcctId').val() == '') {
			alert('转入账户不能为空！');
			return false;
		}
		if ($('#transSrcAcctId').val() == $('#transDestAcctId').val()) {
			alert('转出账户与转入账户不能为同一个账户！');
			return false;
		}
		$.ajax({
			type: "POST",
			url: "business/com.heavenbird.book.action.BillAction?action=newTransBill",
			data: $('#newTransForm').serialize(),
			dataType: "json",
			success: function(data, textStatus) {
				if(data.success == true) {
					alert('记录新增成功！');
					$('#newTransForm')[0].reset();
					now = date2strYYYYMMDD(new Date());
					$('#transDate').val(now);
				} else {
					alert(data.msg);
				}
			}
		});
	});
	
	$('#newBorwLendBillBtn').click(function(){
		if ($('#borwLendDate').val() == null || $('#borwLendDate').val() == '') {
			alert('时间不能为空！');
			return false;
		}
		if ($('#borwLendTitle').val() == null || $('#borwLendTitle').val() == '') {
			alert('名称不能为空！');
			return false;
		}
		if ($('#borwLendAmount').val() == null || $('#borwLendAmount').val() == '') {
			alert('金额不能为空！');
			return false;
		}
		if ($('input:radio[name="borwLendType"]:checked').val() == null || $('input:radio[name="borwLendType"]:checked').val() == '') {
			alert('类型不能为空！');
			return false;
		}
		if ($('#borwLendAcctId').val() == null || $('#borwLendAcctId').val() == '') {
			alert('账户不能为空！');
			return false;
		}
		$.ajax({
			type: "POST",
			url: "business/com.heavenbird.book.action.BillAction?action=newBorwLendBill",
			data: $('#newBorwLendForm').serialize(),
			dataType: "json",
			success: function(data, textStatus) {
				if(data.success == true) {
					alert('记录新增成功！');
					$('#newBorwLendForm')[0].reset();
					now = date2strYYYYMMDD(new Date());
					$('#borwLendDate').val(now);
				} else {
					alert(data.msg);
				}
			}
		});
	});
	
	$('#newCredCardBillBtn').click(function(){
		if ($('#credCardDate').val() == null || $('#credCardDate').val() == '') {
			alert('时间不能为空！');
			return false;
		}
		if ($('#credCardTitle').val() == null || $('#credCardTitle').val() == '') {
			alert('名称不能为空！');
			return false;
		}
		if ($('#credCardAmount').val() == null || $('#credCardAmount').val() == '') {
			alert('名称不能为空！');
			return false;
		}
		if ($('#credCardSrcAcctId').val() == null || $('#credCardSrcAcctId').val() == '') {
			alert('还款账户不能为空！');
			return false;
		}
		if ($('#credCardDestAcctId').val() == null || $('#credCardDestAcctId').val() == '') {
			alert('信用卡账户不能为空！');
			return false;
		}
		if ($('#credCardSrcAcctId').val() == $('#credCardDestAcctId').val()) {
			alert('还款账户不能与信用卡账户相同！');
			return false;
		}
		$.ajax({
			type: "POST",
			url: "business/com.heavenbird.book.action.BillAction?action=newCredCardBill",
			data: $('#newCredCardForm').serialize(),
			dataType: "json",
			success: function(data, textStatus) {
				if(data.success == true) {
					alert('记录新增成功！');
					$('#newCredCardForm')[0].reset();
					now = date2strYYYYMMDD(new Date());
					$('#credCardDate').val(now);
				} else {
					alert(data.msg);
				}
			}
		});
	});
	
	$('#viewBill').hide();
	
	$('#newBillBtn').click(function() {
		$('#viewBill').hide();
		$('#newBill').show();
		$('#newBillBtn').parent().addClass('active');
		$('#viewBillBtn').parent().removeClass('active');
	});
	
	$('#viewBillBtn').click(function() {
		$('#viewBill').show();
		$('#newBill').hide();
		$('#viewBillBtn').parent().addClass('active');
		$('#newBillBtn').parent().removeClass('active');
	});
});
</script>